﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WZ.DC.Config.Configuration;

namespace WZ.DC.Config
{
    public class DBConfig<T>
    {

        public string DBConnStr
        {
            get
            {
                DCConfiguracionBase config = Config.Configuration.DCConfiguration.GetConfig();
                string entity = typeof(T).Namespace;
                var dataBase = config.DataBaseList.FirstOrDefault(a => entity.Contains(a.Name));
                if (dataBase != null)
                {
                    return dataBase.DataBaseElement.ConnStr;
                }
                return config.DefaultDataBase.ConnStr;
            }
        }
    }
}
